<html lang="en">
<head>
    <title>游记文章管理</title>
    <#include "../common/header.ftl">
    <script type="text/javascript">
        $(function () {
            //查询
            $(".clickBtn").click(function () {
                $("#currentPage").val(1);
                $("#searchForm").submit();
            });
            //发布： 改状态
            $(".changeStateBtn").click(function () {
                var state = $(this).data("state");
                var id = $(this).data("id");
                $.get("/travel/changeState", {state:state, id:id}, function (data) {
                    if(data.success){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            });
            //查看文章 按钮
            $('.lookBtn').click(function () {
                var id = $(this).data('id'); //根据id查询文章内容
                $.get('/travel/content', {id: id}, function (data) {
                    // 注意自己的这个data返回来的是什么，需要data里面的什么东西
                    $('#inputModal .modal-body').html(data.content);
                    $('#inputModal').modal('show');
                })
            });
        })
    </script>
</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="travel">

<div class="container-fluid " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">游记管理</h1>
                </div>
            </div>
            <#setting number_format="#">
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <label for="keyword">关键字:</label>
                <input class="form-control" name="keyword" placeholder="请输入标题" value="${qo.keyword!}">
                <div class="form-group">
                    <label for="state">状态:</label>
                    <select name="state" id="state" class="form-control">
                        <option value="-1">全部</option>
                        <option value="1">待发布</option>
                        <option value="2">已发布</option>
                        <option value="3">拒绝</option>
                    </select>
                    <script>
                        $("#state").val(${qo.state!});
                    </script>
                </div>
                <button type="button" class="btn btn-primary clickBtn">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>

            <table class="table table-striped table-hover" >
                <thead>
                    <tr>
                        <th>序号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
               <#list pageInfo.list as entity>
                   <tr>
                       <td>${entity_index+1}</td>
                       <td>${entity.title!}</td>
                       <td><img src="${entity.coverUrl!}" width="100px" height="60px"> </td>
                       <td>${(entity.dest.name)!}</td>
                       <td>${(entity.author.nickname)!}</td>
                       <td>${entity.stateDisplay}</td>
                       <td>
                           <#if entity.state = 1>
                                <a class="btn btn-default btn-xs changeStateBtn" href="JavaScript:;" data-state="2" data-id="${entity.id}">
                                    <span class="glyphicon glyphicon-tag"></span> 发布
                                </a>
                               <a class="btn btn-danger btn-xs changeStateBtn" href="JavaScript:;" data-state="3" data-id="${entity.id}">
                                   <span class="glyphicon glyphicon-tag"></span> 拒绝
                               </a>
                           <#else>
                                <a class="btn btn-danger btn-xs changeStateBtn" href="javascript:;" data-state='1' data-id="${entity.id}">
                                    <span class="glyphicon glyphicon-minus-sign"></span> 下架
                                </a>
                           </#if>
                           <a class="btn btn-info btn-xs lookBtn" data-id="${entity.id}">
                               <span class="glyphicon glyphicon-edit"></span> 查看
                           </a>

                       </td>
                   </tr>
               </#list>
            </table>
            <#--分页-->
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<!-- 模态框必须作为body的子标签，查看文章内容 -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">查看文章内容</h4>
            </div>
            <div class="modal-body">

            </div>
        </div>
    </div>
</div>

</body>
</html>